package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldProjectPostDto;
import com.cleaningcloud.cld.domain.vo.CldProjectPostSetVo;
import com.cleaningcloud.cld.domain.vo.CldProjectSetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldProjectPost;
import com.cleaningcloud.cld.service.ICldProjectPostService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 项目岗位Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/post")
public class CldProjectPostController extends BaseController
{
    @Autowired
    private ICldProjectPostService cldProjectPostService;

    /**
     * 查询项目岗位列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CldProjectPostDto cldProjectPost)
    {
        startPage();
        List<CldProjectPostSetVo> list = cldProjectPostService.selectCldProjectPostList(cldProjectPost);
        return getDataTable(list);
    }


    /**
     * 项目管理 -> 查看项目岗位
     */
    @GetMapping("/getProjectPostList")
    public TableDataInfo getProjectPostList(CldProjectPostDto cldProjectPostDto)
    {
        startPage();
        List<CldProjectPostSetVo> list = cldProjectPostService.getProjectPostList(cldProjectPostDto);
        return getDataTable(list);
    }


    /**
     * 获取项目岗位详细信息
     */
    @GetMapping(value = "/{projectPostId}")
    public AjaxResult getInfo(@PathVariable("projectPostId") Long projectPostId)
    {
        return success(cldProjectPostService.selectCldProjectPostByProjectPostId(projectPostId));
    }

    /**
     * 新增项目岗位
     */
    @Log(title = "项目岗位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldProjectSetVo cldProjectPost)
    {
        return toAjax(cldProjectPostService.insertCldProjectPost(cldProjectPost));
    }

    /**
     * 新增项目岗位
     */
    @Log(title = "项目岗位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldProjectPost cldProjectPost)
    {
        return toAjax(cldProjectPostService.updateCldProjectPost(cldProjectPost));
    }



    /**
     * 项目小组 修改项目岗位
     */
    @Log(title = "项目岗位", businessType = BusinessType.UPDATE)
    @PutMapping("/updatePost")
    public AjaxResult updatePost(@RequestBody CldProjectPost cldProjectPost)
    {
        return toAjax(cldProjectPostService.updateCldProjectPost(cldProjectPost));
    }


    /**
     * 项目在岗人员解绑
     */
    @PostMapping("/unbinding")
    public AjaxResult unbinding(@RequestBody CldProjectPost cldProjectPost)
    {
        return toAjax(cldProjectPostService.unbindingCldProjectPost(cldProjectPost));
    }


   


}
